$def with (d, matches)

$# :param web.Storage d: form data
$# :param list matches:

$var title: $_("Add a book")

<div id="contentHead">
    <h1>$_("Add a Book")</h1>
    <p class="instruct">
        $:_("One moment... It looks like we already have <em>some potential matches</em> for <b>%(title)s</b> by <b>%(author)s</b>.", title=d.title, author=d.author_names[0])
        <br/><br/>
        $_("Rather than creating a duplicate record, please click through the result you think best matches your book.")
    </p>
</div>

<div id="contentBody">
    <div id="searchResults">
        <ul id="siteSearch" class="list-books">
        $for work in matches:
            <li class="workResult" id="$work.key.split('/')[-1]">
                <span class="bookcover">
                    <a href="javascript:;" title="$_('Select this book')"><img src="$work.cover_url" height="70"/></a>
                </span>
                <span class="details">
                    <span class="resultTitle">
                        <h3 class="booktitle"><a href="javascript:;" title="$_('Select this book')">$work.title</a></h3>
                        <span class="bookauthor">$_('by')
                            $for a in work.authors:
                                $a.name$cond(not loop.last, ',')
                        </span>
                        <span class="resultPublisher">$ungettext('1 edition', '%(count)s editions', work.edition_count, count=commify(work.edition_count))
                        $if work.first_publish_year:
                            <span "smallest">&bull;</span> $_('First published in %(year)d', year=work.first_publish_year)
                        </span>
                    </span>
                </span>
            </li>
        </ul>
    </div>

    <p class="small sansserif clearfix">None of these match the book I want to add. <a href="javascript:;" id="bookAddCont">Continue</a>.</p>

    <form method="POST" id="addbook" class="olform addbook1 hidden" name="edit">
        <input type="hidden" id="work" name="work" value=""/>
        <input type="hidden" name="title" value="$d.title"/>
        <input type="hidden" name="author_key" value="$d.author_key"/>
        <input type="hidden" name="publisher" value="$d.publisher"/>
        <input type="hidden" name="publish_date" value="$d.publish_date"/>
        <input type="hidden" name="id_name" value="$d.id_name"/>
        <input type="hidden" name="id_value" value="$d.id_value"/>
    </form>
</div>

<script type="text/javascript">
<!--
window.q.push(function() {
    \$("#siteSearch a").click(function() {
        var li = \$(this).parents('li:first');
        \$("input#work").val("/works/" + li.attr("id"));
        \$("form#addbook").submit();
    });

    \$("#bookAddCont").click(function() {
        \$("input#work").val("none-of-these");
        \$("form#addbook").submit();
    });
});
//-->
</script>
